package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.db.domain.system.PcSilverConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.service.IPcSilverConfigService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 银藻系统配置Controller
 * 
 * @author ruoyi
 * @date 2022-07-27
 */
@Api(value = "银藻系统配置",tags ="银藻系统配置")
@RestController
@RequestMapping("/silver/config")
public class PcSilverConfigController extends BaseController
{
    private static Logger log = LoggerFactory.getLogger(PcSilverConfigController.class);
    @Autowired
    private IPcSilverConfigService pcSilverConfigService;

    /**
     * 查询银藻系统配置列表
     */
    @ApiOperation(value = "查询银藻系统配置列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcSilverConfig",value="银藻系统配置",paramType="form")
    })
    @RequiresPermissions("system:config:list")
    @GetMapping("/list")
    public TableDataInfo list(PcSilverConfig pcSilverConfig)
    {
        try {
            startPage();
            List<PcSilverConfig> list = pcSilverConfigService.selectPcSilverConfigList(pcSilverConfig);
            return getDataTable(list);
        }catch (Exception e){
            log.error("银藻系统配置发生异常",e);
        }
        return null;
    }

    /**
     * 导出银藻系统配置列表
     */
    @ApiOperation(value = "导出银藻系统配置列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcSilverConfig",value="银藻系统配置",dataType="PcSilverConfig")
    })
    @RequiresPermissions("system:config:export")
    @Log(title = "银藻系统配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response,@RequestBody PcSilverConfig pcSilverConfig)
    {
        try {
            List<PcSilverConfig> list = pcSilverConfigService.selectPcSilverConfigList(pcSilverConfig);
            ExcelUtil<PcSilverConfig> util = new ExcelUtil<PcSilverConfig>(PcSilverConfig.class);
            util.exportExcel(response, list, "银藻系统配置数据");
        }catch (Exception e){
            log.error("银藻系统配置发生异常",e);
        }
    }

    /**
     * 获取银藻系统配置详细信息
     */
    @ApiOperation(value = "获取银藻系统配置详细信息")
    @ApiImplicitParam(name="id",value="银藻系统配置")
    @RequiresPermissions("system:config:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        try {
            return AjaxResult.success(pcSilverConfigService.selectPcSilverConfigById(id));
        }catch (Exception e){
            log.error("银藻系统配置发生异常",e);
        }
        return AjaxResult.error("银藻系统配置异常");
    }

    /**
     * 新增银藻系统配置
     */
    @ApiOperation(value = "新增银藻系统配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcSilverConfig",value="银藻系统配置",dataType="PcSilverConfig")
    })
    @RequiresPermissions("system:config:add")
    @Log(title = "银藻系统配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PcSilverConfig pcSilverConfig)
    {
        try {
            int i=pcSilverConfigService.insertPcSilverConfig(pcSilverConfig);
            return toAjax(i);
        }catch (Exception e){
            log.error("新增银藻系统配置发生异常",e);
        }
        return AjaxResult.error("银藻系统配置异常");
    }

    /**
     * 修改银藻系统配置
     */
    @ApiOperation(value = "修改银藻系统配置")
    @ApiImplicitParams({
            @ApiImplicitParam(name="pcSilverConfig",value="银藻系统配置",dataType="PcSilverConfig")
    })
    @RequiresPermissions("system:config:edit")
    @Log(title = "银藻系统配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PcSilverConfig pcSilverConfig)
    {
        try {
            int i=pcSilverConfigService.updatePcSilverConfig(pcSilverConfig);
            return toAjax(i);
        }catch (Exception e){
            return AjaxResult.error(e.getMessage());
        }
   }

    /**
     * 删除银藻系统配置
     */
    @ApiOperation(value = "删除银藻系统配置")
    @ApiImplicitParam(name="ids",value="银藻系统配置")
    @RequiresPermissions("system:config:remove")
    @Log(title = "银藻系统配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        try {
            int i=pcSilverConfigService.deletePcSilverConfigByIds(ids);
            return toAjax(i);
        }catch (Exception e){
            log.error("删除银藻系统配置发生异常",e);
        }
        return AjaxResult.error("银藻系统配置异常");
    }
}
